<template>
  <div>
    <!-- 搜索 -->
    <div class="search-box">
      <span class="address">上海</span>
      <van-search v-model="value" placeholder="请输入搜索关键词" />
    </div>

    <van-icon size="25" name="location-o" />
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in swiperlist" :key="item.id"
        ><img :src="'http://liufusong.top:8080' + item.imgSrc" alt=""
      /></van-swipe-item>
    </van-swipe>

    <!-- <div class="nav">
      <ul class="item">
        <li>
          <img src="http://liufusong.top:8080/img/swiper/2.png" alt="" />
          <h2>整租</h2>
        </li>
        <li>
          <img src="http://liufusong.top:8080/img/swiper/2.png" alt="" />
          <h2>整租</h2>
        </li>
        <li>
          <img src="http://liufusong.top:8080/img/swiper/2.png" alt="" />
          <h2>整租</h2>
        </li>
        <li>
          <img src="http://liufusong.top:8080/img/swiper/2.png" alt="" />
          <h2>整租</h2>
        </li>
      </ul>
    </div> -->
    <!--出租分类 -->
  <div class='sort'>
     <van-grid>
      <van-grid-item
        to="/layout/findhouse"
        icon="wap-home-o"
        text="整租"
      />

      <van-grid-item
        to="/layout/findhouse"
        icon="friends-o"
        text="合租"
      />
      <van-grid-item
        to="/map"
        icon="location-o"
        text="地图找房"
      />
      <van-grid-item
        to="/login"
        icon="hotel-o"
        text="去出租"
      />
    </van-grid>
  </div>

    <div class="group">
      <!-- 租房小组 -->
      <van-nav-bar left-text="租房小组" right-text="更多" />
      <!-- n租房小组内容 -->
      <van-grid direction="horizontal" :column-num="2">

          <van-grid-item
          v-for="item in hireHouse"
          :key="item.id"
        >
        <img :src="'http://liufusong.top:8080' + item.imgSrc" alt="" class="left" />
          <div class="right">
            <p class="reghtP">{{ item.title }}</p>
            {{ item.desc }}
          </div>
        </van-grid-item>

      </van-grid>
    </div>
  </div>
</template>

<script>
import { getSwiper, getHireHouse } from '@/api/recommend.js'
export default {
  data () {
    return {
      value: '',
      swiperlist: [],
      hireHouse: []
    }
  },

  created () {
    this.getSwiperview()
    this.getHireHouseview()
  },

  methods: {
    onSearch () {
      console.log(11)
    },
    // 轮播图
    async getSwiperview () {
      const res = await getSwiper()
      this.swiperlist = res.data.body
    },
    // 租房小组
    async getHireHouseview () {
      const res = await getHireHouse()
      this.hireHouse = res.data.body
    }
  }
}
</script>

<style scoped lang="less">
// 搜索
.search-box {
  margin-left: 10px;
  position: absolute;
  top: 25px;
  width: 310px;
  padding: 0 10px;
  z-index: 2;
  display: flex;
  height: 34px;
  line-height: 34px;
  background-color: #fff;
  justify-content: space-around;
  .van-search {
    border: none;
    flex: 1;
    // width: 300px;
  }
}
.van-icon {
  position: absolute;
  z-index: 2;
  right: 10px;
  top: 30px;
}
// l轮播图
.my-swipe {
  // position: absolute;

  .van-swipe-item {
    color: #fff;
    font-size: 20px;
    // line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
    width: 375px;
    height: 212px;
    img {
      width: 100%;
    }
  }
}

  // 出租分类
 .sort{
    .van-cell__title {
    font-size: 18px;
    font-weight: 700;
  }
  /deep/.van-grid {
    // background-color: pink;
    height: 121px;
    line-height: 121px;
    padding: 10px 0;
    .van-grid-item {
      // height: 101px;
      .van-grid-item__icon {
        font-size: 50px;
      }
      .van-grid-item__content{
        padding: 0;
      }
    }
   .van-grid-item__text {
      font-size: 14px;
    }
  }
 }

.group {
  padding:0 10px;
  height: 187px;
  background-color: #f6f5f6;
/deep/.van-nav-bar {
    background-color: #f6f5f6;
  }
  /deep/.van-nav-bar__text {
    color: #000;
  }
    /deep/.van-nav-bar__left {
    .van-nav-bar__text {
      font-weight: 600;
      font-size: 15px;
    }
  }

  /deep/.van-nav-bar__right {
    .van-nav-bar__text {
      color: #787d82;
    }
  }

  .van-grid{
    background-color: #f6f5f6;
padding: 0px;
  }
    /deep/.van-grid-item__content {
   padding: 0;
   margin-left: 10px;
  }
  /deep/.van-grid-item {
    text-align: left;
    height: 60px;
   margin-bottom: 10px;

  }
   .left {
    width: 50px;
    height: 50px;
    margin: 0 10px;
  }

}
  .right {
      font-size: 14px;

    .reghtP {
      margin: 0;
    }
  }

</style>
